﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KnowledgeCommunity.Web.DbHelper;

namespace KnowledgeCommunity.Web.Controllers
{
    public class AttentionController : Controller
    {
        AttentionHelper myAttentionHelper = new AttentionHelper();
        //
        // GET: /Attention/

        [Authorize]
        public ActionResult Index()
        {
            string user = HttpContext.User.Identity.Name;
            var model = myAttentionHelper.FindByUserName(user);
            ViewData["AttentionList"] = model;
            return View();
        }

        [Authorize]
        public ActionResult Delete(int id)
        {
            var model = myAttentionHelper.FindById(id);
            return View(model);
        }

        [Authorize]
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            bool n = myAttentionHelper.Delete(id);
            if (n)
            {
                return RedirectToAction("Index", "Attention");
            }
            else
            {
                return RedirectToAction("Error", "Notice", new { type = 2 });
            }
        }

    }
}
